<?php
/*
	用户端公共文件，访问用户端时默认加载
*/
defined('BY_JYA') or exit('error');
cfc('core')->checklogin();
if($_RQ['is_access'] && $_RQ['action']!='login' && $_RQ['action']!='apply' && $_RQ['action'] !='info'){
	$member=$this->model('member')->checkmember('',true);
}elseif($_RQ['action'] !='myshop' && $_RQ['action']!='apply' && $_RQ['action']!='login'){
	$member=$this->model('member')->checkmember('',false);
}
if($_SESSION['container']=='wxapp' && !$_SESSION['fromh5wxapp']){
	$iswxapp=1;
}
if(($_RQ['is_access'] || $iswxapp) && (!$member['is_agent'] || $member['stop']) && $_RQ['action'] !='apply'){
	$can_apply=true;
	$return['can_apply']=$can_apply;	
	$return['member']=$member;
	if($member['fromuser']){
		$return['agent']=model('core/member')->detail($member['fromuser'],array('nickname','avatar'));
		$return['agent_name']=$return['agent']['nickname'];
	}
	$return['htmls']=$this->template_url('apply');
	$return['page_setting']=$this->plugin_setting('page');
	$return['apply_setting']=$this->plugin_setting('apply');
	if(!$this->setting['no_indexurl']){
		$return['index_url']=$this->setting['index_url']?:'jy_dayfeeshop/index/';
	}
	$return['item']=model('core/member')->detail($_SESSION['uid'],array('nickname','avatar','realname','mobile','wechat'));	
	$return['item']['oldmobile']=$return['item']['mobile'];
	$setting=uni_setting('register');
	$return['item']['login_type']=$setting['login_type'];
	$return['open_duodai']=$this->setting['open_duodai'];
	$return['item']['area']=array('duodai'=>'');
	$return['province']=$this->model()->available_areas();
	$return['level_types']=$this->level_types;
	$conditions=array();
	foreach($return['level_types'] as $k=>$lv){
		$levelset=pdo_getcolumn('jy_dayfee_level',array('uniacid'=>$_SESSION['uniacid'],'level'=>$k),'conditions');
		$conditions[$k]=$levelset?json_decode($levelset,true):array('no'=>1);
	}
	$return['conditions']=$conditions;
	if($iswxapp){		
		exi('','','jy_dayfee/apply/');
	}
	exi($return);
}

